package com.lianniu.mgr.productAssess.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.lianniu.mgr.base.BaseResult;
import com.lianniu.mgr.pagination.PaginationInfo;
import com.lianniu.mgr.product.model.ProductBrandVo;
import com.lianniu.mgr.productAssess.model.ProductAssessVo;
import com.lianniu.mgr.productAssess.service.IProductAssessService;

@Controller
@RequestMapping("/rest/productAssess")
public class ProductAssessRestController {
	
	private final static Logger logger = Logger.getLogger(ProductAssessRestController.class);
	
	@Autowired
	private IProductAssessService productAssessService;
	
	@RequestMapping(value="/productAssessList",method={RequestMethod.GET,RequestMethod.POST})
	  public @ResponseBody BaseResult productAssessList(HttpServletRequest request, ProductAssessVo curVo, PaginationInfo paginationInfo)
	  {
	       logger.info("ProductAssessRestController  productAssessList begin.");
	       try {
	           
	           logger.info("productAssessList begin.");          
	           BaseResult baseResult = productAssessService.selectByProductAssessForPage(curVo, paginationInfo);
	           logger.info("productAssessList end.");
	           logger.info("ProductAssessRestController productAssessList end.");
	           return baseResult;
	       } catch (Exception e) {
	       logger.error("ProductAssessRestController productAssessList error:" + e.getMessage());
	       logger.error("ProductAssessRestController productAssessList end.");
	       return BaseResult.exception(e.getMessage());
	     }
	  }
	
	@RequestMapping(value="/selectProductAssessById",method={RequestMethod.GET,RequestMethod.POST})
	  public @ResponseBody BaseResult selectProductAssessById(HttpServletRequest request,ProductAssessVo curVo) {
	        logger.info("ProductAssessRestController selectProductAssessById begin.");
	        try {
	                    
	          BaseResult baseResult = productAssessService.selectById(curVo);
	          logger.info("selectProductAssessById end.");
	          logger.info("ProductAssessRestController selectProductAssessById end.");
	          return baseResult;
	        } catch (Exception e) {
	          logger.error("ProductAssessRestController selectProductAssessById error:" + e.getMessage());
	          logger.error("ProductAssessRestController selectProductAssessById end.");
	          return BaseResult.exception(e.getMessage());
	        }
	        
	  } 
	
	@RequestMapping(value = {"/productAssessDel"}, method = RequestMethod.POST)
	  public @ResponseBody BaseResult productAssessDel(HttpServletRequest request) {
	      logger.info("ProductAssessRestController productAssessDel begin.");
	     try {          
	          logger.info("productAssessDel begin.");
	          BaseResult baseResult = productAssessService.deleteProductAssess(request.getParameter("ids").split(","));		
	          logger.info("productAssessDel baseResult:" + JSON.toJSONString(baseResult));
	          logger.info("productAssessDel end.");
	          
	          logger.info("ProductAssessRestController productAssessDel end.");
	          return baseResult;

	    } catch (Exception e) {
	      logger.error("ProductAssessRestController productAssessDel error:" + e.getMessage());
	      logger.info("ProductAssessRestController productAssessDel end.");
	      return BaseResult.exception(e.getMessage());
	    }

	  }
	
}
